// 主界面
;define(function(require, exports, module) {
    'use strict';
    var util = require("util");
    var base = require("base");
    var router = require("../hash/pageRouter");
    var dialog = require("dialog");
    var validate = require("validate");
    var databind = require("databind");
    var css_detail_info = require("./clientManage_financeEvidentiary1.css");
//    var detail_info = require("./clientManage_details.js");
//    var css_detail_info = require("./clientManage_details.css");
    var html_auditState_Yes = require("../client/clientManage_auditStateYes.html");
    var html_auditState_No = require("../client/clientManage_auditStateNo.html");
    var pageIndex = 1,
        pageSize = 20,
        totalPageCount = 1,
        totalRecordCount = 0; //分页初始化
    var enterpriseId = "";
     var businessLicenceImage="";
    var certificateImage="";
    var legalPersonFrontImage= "";
    var legalPersonBackImage = "";
    var qualificationsImage = "";
    var creditReportImage = "";
    var str ="",
    	str1 = "",
    	str2 = "";
    var init = function(page){
    	$(".nav_active").removeClass("nav_active1");
		$("#financeEvidentiary").addClass("nav_active1");
    	enterpriseId = page.params.enterpriseId||base.getUrlParam("enterpriseId");
		businessLicenceImage = page.params.businessLicenceImage||base.getUrlParam("businessLicenceImage");
     	certificateImage = page.params.certificateImage||base.getUrlParam("certificateImage");
    	legalPersonFrontImage= page.params.legalPersonFrontImage||base.getUrlParam("legalPersonFrontImage");
     	legalPersonBackImage = page.params.legalPersonBackImage||base.getUrlParam("legalPersonBackImage");
    	qualificationsImage = page.params.qualificationsImage||base.getUrlParam("qualificationsImage");
     	creditReportImage = page.params.creditReportImage||base.getUrlParam("creditReportImage");
     	
     	str = "<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + businessLicenceImage + "'><img class=\"evidentiaryImg\" src=\"/finance/api/v1.0/downloadFile.file?fileUuid="+businessLicenceImage+
     	"\">企业法人营业执照</a><a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + certificateImage + "'><img class=\"evidentiaryImg\" src=\"/finance/api/v1.0/downloadFile.file?fileUuid="+certificateImage+"\">组织机构代码证</a>";
		
		$("#businessLicence1").append(str);
		str1 = "<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + legalPersonFrontImage + "'><img class=\"evidentiaryImg\" src=\"/finance/api/v1.0/downloadFile.file?fileUuid="+legalPersonFrontImage+
     	"\">法人证件照片正面</a><a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + legalPersonBackImage + "'><img class=\"evidentiaryImg\" src=\"/finance/api/v1.0/downloadFile.file?fileUuid="+legalPersonBackImage+"\">法人证件照片 反面</a>";
		$("#legalPerson1").append(str1);
		str2 = "<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + qualificationsImage + "'><img class=\"evidentiaryImg\" src=\"/finance/api/v1.0/downloadFile.file?fileUuid="+qualificationsImage+
     	"\">公司资质</a><a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + creditReportImage + "'><img class=\"evidentiaryImg\" src=\"/finance/api/v1.0/downloadFile.file?fileUuid="+creditReportImage+"\">信用报告</a>";
		$("#qualificationsImage1").append(str2);
//		detail_info.init(page);
		initEvent();
		
		router.init();
    };
	var initEvent = function(){
		//若未登录，则返回登陆页面
		if(base.getData("sid")==null||base.getData("sid")==""||base.getData("sid")==undefined){
			top.location.href="../login/login.html";
		}
		
		//点击企业基本信息
		$(".enterpriseInfo").on("click", function() {
			router.route("client/clientManage_details.html?enterpriseId=" + enterpriseId, true);
		});

		$(".financeSituation").on("click", function() {
			router.route("client/clientManage_financeSituation.html?enterpriseId=" + enterpriseId +
				"&businessLicenceImage=" + businessLicenceImage + "&certificateImage=" + certificateImage +
				"&legalPersonFrontImage=" + legalPersonFrontImage + "&legalPersonBackImage=" + legalPersonBackImage +
				"&qualificationsImage=" + qualificationsImage + "&creditReportImage=" + creditReportImage, true);
		});
	
		//点击企业基本信息
		$("#clientManageDetailIntact .enterpriseInfo1").on("click", function() {
//			router.route("client/clientManage_details.html?enterpriseId=" + enterpriseId, true);
			location.href = "../client/clientManageDetailIntact.html?enterpriseId=" + enterpriseId;
		});
		

		$(".financeSituation1").on("click", function() {
			router.route("client/clientManage_financeSituation1.html?enterpriseId=" + enterpriseId +
				"&businessLicenceImage=" + businessLicenceImage + "&certificateImage=" + certificateImage +
				"&legalPersonFrontImage=" + legalPersonFrontImage + "&legalPersonBackImage=" + legalPersonBackImage +
				"&qualificationsImage=" + qualificationsImage + "&creditReportImage=" + creditReportImage, true);
		});

		//证明材料
		$(".financeEvidentiary1").on("click", function() {
			router.route("client/clientManage_financeEvidentiary1.html?enterpriseId=" + enterpriseId +
				"&businessLicenceImage=" + businessLicenceImage + "&certificateImage=" + certificateImage +
				"&legalPersonFrontImage=" + legalPersonFrontImage + "&legalPersonBackImage=" + legalPersonBackImage +
				"&qualificationsImage=" + qualificationsImage + "&creditReportImage=" + creditReportImage, true);
		});
    };
    
    return {
        init:init
    };
});